import { http } from "@/utils/http";

export type commonResult<T> = {
  code: number;
  msg: string;
  result: T;
};

export type infoType = {

  id?: number,
  userId?: number,
  userName?: string,
  unityId?: number,
  unityName?: string,
  familyId?: number,
  familyName?: string,
  deviceIds?: number[],
  devices?: any[],
  superviseUnityId?: number,
  superviseUnityName?: string,
  city?: string,
  phone?: string,
  updatedAt?: string,
}
export type infoTypeList = {
  data: infoType[];
  total: number;
};

const List = '/system/device/v2/family/empowers';
const Url = '/system/device/v2/family/empower';
export const getList = (params?: object) => {
  return http.request<commonResult<infoTypeList>>("get", List, {
    params
  });
};
export const getInfo = (params?: object) => {
  return http.request<commonResult<{ data: infoType }>>("get", Url, {
    params
  });
};
export const addInfo = (data?: object) => {
  return http.request<commonResult<any>>("post", Url, {
    data
  });
};
export const editInfo = (data?: object) => {
  return http.request<commonResult<any>>("put", Url, {
    data
  });
};
export const deleteInfo = (data?: object) => {
  return http.request<commonResult<any>>("delete", Url, {
    data
  });
};
/** 1.2.15.7根据家庭id查询授权设备 */
export const getDeviceList = (params?: object) => {
  return http.request<commonResult<any>>("get", '/system/device/v2/family/devices', {
    params
  });
};